import {
    SET_ADDVISIBLE,
    SET_DELVISIBLE,
    SET_DELID,
    SET_MODALTITLE,
    SET_MODALFORM,
    SET_BROKERVISIBLE
} from '../actionType'

const initState = {
    delVisible: false,
    delId: "",
    addVisible: false,
    modalTitle: "",
    modalForm:{},
    brokerVisible:false,
};

const houseReducer = (state = initState, action) => {
    let newState = JSON.parse(JSON.stringify(state));
    let {
        type,
        payload
    } = action;
    switch (type) {
        case SET_ADDVISIBLE: {
            newState.addVisible = payload;
            return newState
        }
        case SET_DELVISIBLE: {
            newState.delVisible = payload;
            return newState
        }
        case SET_DELID: {
            newState.delId = payload;
            return newState
        }
        case SET_MODALTITLE: {
            newState.modalTitle = payload;
            return newState
        }
        case SET_MODALFORM: {
            newState.modalForm = payload;
            return newState
        }
        case SET_BROKERVISIBLE: {
            newState.brokerVisible = payload;
            return newState
        }
        default: {
            return newState
        }
    }
};

export default houseReducer